<div class="section-title">请填写信息</div>
<ul id="x-user-add-form" class="bui-list">
	<li class="bui-btn bui-box clearactive">
		<label class="bui-label" for="user">姓名</label>
		<div class="span1">
			<div class="bui-input">
				<input id="name" type="text" placeholder="请输入姓名" />
			</div>
		</div>
	</li>
	<li class="bui-btn bui-box clearactive">
		<label class="bui-label" for="user">性别</label>
		<div id="x-select-sex" class="bui-select bui-box">
			<div class=""></div>
			<i class="icon-listright"></i>
		</div>
	
	</li>
	<li class="bui-btn bui-box clearactive">
		<label class="bui-label" for="user">手机号码</label>
		<div class="span1">
			<div class="bui-input">
				<input id="tel" type="number" placeholder="请输入你的手机号码" />
			</div>
		</div>
	</li>
	<li class="bui-btn bui-box clearactive">
		<label class="bui-label" for="user">工号</label>
		<div class="span1">
			<div class="bui-input">
				<input id="jnum" type="text" placeholder="请输入工号" />
			</div>
		</div>
	</li>
	<li class="bui-btn bui-box clearactive">
		<label class="bui-label" for="user">账号</label>
		<div class="span1">
			<div class="bui-input">
				<input id="uname" type="text" placeholder="请输入账号" />
			</div>
		</div>
	</li>
	
	<li class="bui-btn bui-box clearactive">
		<label class="bui-label" for="user">密码</label>
		<div class="span1">
			<div class="bui-input">
				<input id="pwd" type="password" placeholder="请输入密码" />
			</div>
		</div>
	</li>
	
	
	<li class="bui-btn bui-box clearactive">
		<label class="bui-label" for="user">上级</label>
		<div class="span1">
			<div class="bui-input">
				<input id="parent" type="text" disabled="disabled"/>
			</div>
		</div>
	</li>
</ul>
<div class="container-xy">
  <div class="bui-btn round primary x-user-add-btn">确认添加</div>
</div>

<script>

	//var 
	 $.ajax({
		type:'get',
		url:'/user/parent',
		success:function(r){
			$('#parent').attr('value', r.name);
		}
	}); 
	

	bui.select({
		trigger:"#x-select-sex",
		title: "请选择性别",
		data: [{
			"name":"男",
			"value":"1"
		},{"name":"女",
			"value":"0"
		}]
	});
	
	$('.x-user-add-btn').click(function(e){
		var name = $('#x-user-add-form #name').val();
		var sex = $('#x-user-add-form #x-select-sex').attr('value');
		var jnum = $('#x-user-add-form #jnum').val();
		var uname = $('#x-user-add-form #uname').val();
		var pwd = $('#x-user-add-form #pwd').val();
		var tel = $('#x-user-add-form #tel').val();
		$.ajax({
			type:'post',
			url:'/user',
			data:{
				'name':name,
				sex:sex,
				jnum:jnum,
				uname:uname,
				pwd:pwd,
				tel:tel
			},
			success:function(r){
				bui.alert('添加成功',function(){
					bui.back();
				});
				/* setTimeout(function(){
					bui.back();
				},1000); */
			}
		}); 
	});
	
</script>